var app = getApp(),
    t = app.requirejs('core')
var time = require('../../utils/util.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {
        tab: 0,
        listTab: [],
        list: []
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this
        this.getpeoinfo()
        t.post("goods.mydwon", {}, ((e) => {
            //转化时间戳
            var list = ""
            e.list[0].list.forEach((item, index) => {
                list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                item.createtime = list
                console.log("转化日期后", item.createtime);
            })
            that.setData({
                list: e.list[0]
            })
        }))

    },
    //获取会员数据
    getpeoinfo: function () {
        let that = this
        t.get("goods.mydwon", {}, function (e) {
            console.log(e);
            that.setData({
                listTab: e.list
            })
        })
    },
    tab: function (e) {
        var that = this
        that.setData({
            tab: e.currentTarget.dataset.type
        })
        if (e.currentTarget.dataset.type == 0) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[0].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[0].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[0]
                    })
                }
            }))
        } else if (e.currentTarget.dataset.type == 1) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[1].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[1].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[1]
                    })
                }
            }))
        } else if (e.currentTarget.dataset.type == 2) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[2].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[2].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[2]
                    })
                }
            }))
        } else if (e.currentTarget.dataset.type == 3) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[3].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[3].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[3]
                    })
                }
            }))
        } else if (e.currentTarget.dataset.type == 4) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[4].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[4].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[4]
                    })
                }
            }))
        } else if (e.currentTarget.dataset.type == 5) {
            t.post("goods.mydwon", {}, ((e) => {
                var that = this
                if (e.list[5].list == null || '' || undefined) {
                    that.setData({
                        list: e.list
                    })
                } else {
                    //转化时间戳
                    var list = ""
                    e.list[5].list.forEach((item, index) => {
                        list = time.formatTimeTwo(item.createtime, 'Y/M/D')
                        item.createtime = list
                        // console.log("转化日期后", item.createtime);
                    })
                    that.setData({
                        list: e.list[5]
                    })
                }
            }))
        }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    // onShareAppMessage: function () {

    // }
})